/***************************************************************************
 *   This file is part of KTagger                                          *
 *   Copyright (C) 2010 by Luca Bellonda                                   *
 *   lbellonda _at_ gmail.com                                              *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include "config-ktagger.h"
#include "ControlWindow.h"
#include <QCloseEvent>
#include <KAction>
#include <KActionCollection>

ControlWindow::ControlWindow(KApplication *newApplication, QWidget *parent) : KXmlGuiWindow(parent)
{
    application = newApplication ;
    textArea = new KTextEdit();
    setCentralWidget(textArea);

    KAction* tagsProfile = new KAction(this);
    tagsProfile->setText("Test Activity 'one' on /tmp");
    actionCollection()->addAction("profileOne", tagsProfile);
    connect(tagsProfile, SIGNAL(triggered(bool)), this, SLOT(doTagsProfile()));

    KAction* tagsAction = new KAction(this);
    tagsAction->setText("Set Other Tags");
    actionCollection()->addAction("otherTags", tagsAction);
    connect(tagsAction, SIGNAL(triggered(bool)), this, SLOT(otherTags()));

    KAction* cfgAction = new KAction(this);
    cfgAction->setText("Configure");
    actionCollection()->addAction("configure", cfgAction);
    connect(cfgAction, SIGNAL(triggered(bool)), this, SLOT(cfgAction()));

    KAction* chooseAction = new KAction(this);
    chooseAction ->setText("Choose Profile");
    actionCollection()->addAction("chooseProfile", chooseAction);
    connect(chooseAction, SIGNAL(triggered(bool)), this, SLOT(chooseAction()));

    setupGUI(Default, CONTROL_WINDOW_FILE_PATH);
    textArea->setReadOnly(true);
    textArea->setPlainText("This is a debug informations window, for tests only.");
}

void ControlWindow::closeEvent(QCloseEvent *event)
{
    event->accept();
    if (NULL != application) {
        application->quit();
    }
}

void ControlWindow::otherTags()
{
    emit openOtherTags();
}

void ControlWindow::cfgAction()
{
    emit configure();
}


void ControlWindow::chooseAction()
{
    emit chooseProfile();
}

void ControlWindow::doTagsProfile()
{
    emit tagsProfile();
}
